package com.example.demo.controller;

import com.example.demo.Service.TaskService;
import com.example.demo.pojo.TaskQuantity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author 翁佃峰
 * date:2020/11/1 13:13
 */
@RestController
@RequestMapping("task")
public class TaskController {
    @Autowired
    TaskService taskService;

    /**
     * 根据所给时间段返回各阶段任务数量
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("getTaskStatusQuantityListByPeriod")
    public TaskQuantity getTaskStatusQuantityListByPeriod(String startTime, String  endTime) {

        return taskService.getTaskStatusQuantityListByPeriod(startTime,endTime);
    }

    /**
     * 得到一年中每个月任务各项状态的数量
     * @param year
     * @return
     */
    @GetMapping("getTaskStatusQuatityListByYear")
    public Map<Integer,TaskQuantity> getTaskStatusQuantityListByMonth(int year){
        return taskService.getTaskStatusListByYear(year);
    }
}